﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wrwpf.Controls="clr-namespace:WrWpf.Controls">

	<!--Default PreChange View Animation-->
	<Storyboard x:Key="DefaultPreChangeAnimation">
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)">
			<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
			<SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0"/>
		</DoubleAnimationUsingKeyFrames>
	</Storyboard>

	<!--Default PostChange View Animation-->
	<Storyboard x:Key="DefaultPostChangeAnimation">
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)">
			<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
			<SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="1"/>
		</DoubleAnimationUsingKeyFrames>
	</Storyboard>
	
	<Style TargetType="{x:Type wrwpf.Controls:CalendarMonth}">
		<Setter Property="ViewPreChangeAnimation" Value="{StaticResource DefaultPreChangeAnimation}" />
		<Setter Property="ViewPostChangeAnimation" Value="{StaticResource DefaultPostChangeAnimation}" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type wrwpf.Controls:CalendarMonth}">
					<Border BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            Background="{TemplateBinding Background}"
                            Padding="{TemplateBinding Padding}">
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
							</Grid.RowDefinitions>

							<Grid Grid.Row="0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="*" />
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="Auto" />
								</Grid.ColumnDefinitions>

								<RepeatButton Grid.Column="0" Content="&lt;&lt;"
                                    Command="wrwpf.Controls:CalendarMonth.PreviousYearCommand" />

								<RepeatButton Grid.Column="1" Content="&lt;"
                                    Command="{x:Static ComponentCommands.MoveToPageUp}" />

								<StackPanel Grid.Column="2" HorizontalAlignment="Center" Orientation="Horizontal">
									<TextBlock Name="PART_MonthName" VerticalAlignment="Center"
	                                    Text="{TemplateBinding MonthName}">
	                                    <TextBlock.ContextMenu>
											<ContextMenu ItemsSource="{TemplateBinding MonthNames}" />
	                                    </TextBlock.ContextMenu>
                                    </TextBlock>

									<TextBox IsReadOnly="True" Name="PART_Year"
										Text="{TemplateBinding AbbreviatedYearMonth}" 
										BorderThickness="0"
										Focusable="False"
										Cursor="Arrow"
										VerticalContentAlignment="Center">
									</TextBox>
										
									<StackPanel Focusable="True" VerticalAlignment="Center" Visibility="Collapsed" Name="PART_UpDown">
										<Button Width="22" Height="11" Name="YearIncrease"/>
										<Button Width="22" Height="11" Name="YearDecrease"/>
									</StackPanel>
								</StackPanel>

                                <RepeatButton Grid.Column="3" Content="&gt;"
                                    Command="{x:Static ComponentCommands.MoveToPageDown}" />                                                                <RepeatButton Grid.Column="4" Content="&gt;&gt;"                                    Command="wrwpf.Controls:CalendarMonth.NextYearCommand" />                            </Grid>

							<StatusBar Grid.Row="1" Name="PART_DayNames"
                                    ItemsSource="{TemplateBinding DayNames}">
								<StatusBar.ItemsPanel>
									<ItemsPanelTemplate>
										<UniformGrid Rows="1" />
									</ItemsPanelTemplate>
								</StatusBar.ItemsPanel>
							</StatusBar>

							<UniformGrid Grid.Row="2" Columns="7" Name="PART_Panel"
                                FirstColumn="{TemplateBinding FirstDayInWeek}" />
						</Grid>
					</Border>
					
					<ControlTemplate.Resources>
						<Style TargetType="StatusBarItem">
							<Setter Property="Margin" Value="1" />
							<Setter Property="HorizontalAlignment" Value="Center" />
							<Setter Property="VerticalAlignment" Value="Center" />
						</Style>
					</ControlTemplate.Resources>

					<ControlTemplate.Triggers>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Foreground"
                                    Value="{DynamicResource 
                                        {x:Static SystemColors.GrayTextBrushKey}}" />
						</Trigger>
					</ControlTemplate.Triggers>
					
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>